import {isString} from "@/utils/validator";
import imgOssUtils from "@/utils/ImgOssUtils";

export function transformPagination(page) {
    return {
        start: (page.num - 1) * page.size,
        limit: page.size
    }
}



// ·支付
export function requestPayment(res) {
    const promise=new Promise((resolve, reject)=>{
        uni.requestPayment({
            ...res,
            success: res => {
                resolve(res);
            },
            fail: err => {
                reject(err);
            }
        })
    })
    return promise
}

/**
 * 预览图片
 * @param {Array|String}
 * @param {number} current
 **/
export function previewImage(urls, current,){
    if (isString(urls)) {
        urls = urls.split(",");
    }
    urls = urls.map((item) => {
        return imgOssUtils.loadImage2(item);
    });
    uni.previewImage({
        urls,
        current,
    });
}


